
$(function(){
	selectGoodsList21();
	zhiboguanggao();
});
function zhiboguanggao(){
	$("#zhibotu").html("");
	    $.ajax({
        url:urlcore+"/api/eachPicture/getEachPictureList?type=14&sort=2",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					   if(data.data!=null){
					   	var goodslist="";
					$.each(data.data, function(q,m) {
					if(m.auctionType==1){
					 	goodslist+='<a href="6.0.0dianpu.html?id='+m.auctionId+'"><img style="width: 100%;height: 100%;" onerror="errorImg(this)" src="'+m.imgUrl+'"></a>';
					 }else if(m.auctionType==2){
					 	 goodslist+='<a href="7.0.0goods_detail.html?id='+m.auctionId+'"><img style="width: 100%;height: 100%;" onerror="errorImg(this)" src="'+m.imgUrl+'"></a>';
					 }else if(m.auctionType==3){
					 	goodslist+='<a href="'+m.auctionHttpUrl+'"><img style="width: 100%;height: 100%;" onerror="errorImg(this)" src="'+m.imgUrl+'"></a>';
					 }
					});
					$("#zhibotu").append(goodslist);
					   }
				}else{
					//alert(data.msg);
				}
			},
			error: function() {
				alert("error");
			}
		});
	      
}

var currentPage=1;
var currentPage2=1;
var currentPage3=1;
var currentPage4=1;
var ss4=0;
var ss3=0;
function selectGoodsList23(){
	 if(currentPage3==0||currentPage3==1 || currentPage3==2 || ss3!=0){
	 	   ss=0;
	 	   ss2=0;
	 	   ss4=0;
          currentPage=1;
          currentPage2=1;
          currentPage4=1;
	 	 $("#zhibos2").html("");
	 	 $("#zhibos").html("");
	 	 $("#zhibos4").html("");
	    $.ajax({
        url:urlcore+"/api/zbDirectSeeding/zbDirectSeedingList?current="+currentPage3+"&status=3&directType=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				ss3=data.data.list.length;
				$.each(data.data.list,function(y,n){
    	//var yue = new Date().pattern("MM-dd hh:ss");
    	var  zhibos22='<div class="zhibo_xinxi">'+
    			'<a href="2.2.1zhibo_kaibo_detail.html?zbid='+n.id+'">'+
    				'<div class="zhibo_img">'+
    					'<img onerror="errorImg(this)" src="'+n.imgUrl+'" />'+
    				'</div>'+
    				'<div class="zhibo_wenzi">'+
    					'<dl class="clearfix">'+
    						'<dt>'+
    							'<img onerror="errorImg(this)" src="'+n.user.headImg+'" />'+
    						'</dt>'+
    						'<dd>'+
    							'<h5>'+n.title+'</h5>'+
    					/*	'<span class="zhibo_tip">'+n.startTime+'</span>'+*/
    						'</dd>'+
    					'</dl>';
    					  var zhe=n.packRate.toString().split(".");
    					  $.each(zhe,function(e,q){
    					  	if(e==1){
    					  	zhibos22+='<p>直播期间商品打'+q+'折哦</p>';
    					  	}
    					  });
    				zhibos22+='</div>'+
    			'</a>'+
    		'</div>';
    		      $("#zhibos3").append(zhibos22);
				});
				}
			},
			error: function() {
				alert("error");
			}
		});
	      }
}
	




var ss2=0;
function selectGoodsList22(){
	 if(currentPage2==0||currentPage2==1 || currentPage2==2 || ss2!=0){
	 	   ss=0;
	 	   ss3=0;
	 	   ss4=0;
          currentPage=1;
          currentPage3=1;
          currentPage4=1;
	 	 $("#zhibos").html("");
	 	 $("#zhibos3").html("");
	 	 $("#zhibos4").html("");
	    $.ajax({
        url:urlcore+"/api/zbDirectSeeding/zbDirectSeedingList?current="+currentPage2+"&status=1&directType=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				ss2=data.data.list.length;
				$.each(data.data.list,function(y,n){
				var time=n.startTime; 
var year=time.substr(0,4); 
var index1=time.indexOf("-"); 
var index2=time.lastIndexOf("-"); 
var cha=parseInt(index2)-(parseInt(index1)+1); 
var month=time.substr((parseInt(index1)+1),cha); 
var kg=time.indexOf(" "); 
cha=parseInt(kg)-parseInt(index2); 
var day=time.substr(parseInt(index2)+1,cha); 
var mh=time.indexOf(":"); 
cha=parseInt(mh)-(parseInt(kg)+1); 
var hour=time.substr(parseInt(kg)+1,cha); 
var mh2=time.lastIndexOf(":"); 
cha=parseInt(mh2)-(parseInt(mh)+1); 
var fen=time.substr(parseInt(mh)+1,cha); 

    			var zhibos='<div class="zhibo_xinxi">'+
    			'<a href="2.2.1zhibo_kaibo_detail.html?zbid='+n.id+'">'+
    				'<div class="zhibo_img">'+
    					'<img onerror="errorImg(this)" src="'+n.imgUrl+'" />'+
    				'</div>'+
    				'<div class="zhibo_wenzi">'+
    					'<dl class="clearfix">'+
    						'<dt>'+
    							'<img onerror="errorImg(this)" src="'+n.user.headImg+'" />'+
    						'</dt>'+
    						'<dd>'+
    							'<h5>'+n.title+'</h5>'+
    						'<span class="zhibo_tip">'+month+'月'+day+'号'+hour+'点开播</span>'+
    						'</dd>'+
    					'</dl>';
    					  var zhe=n.packRate.toString().split(".");
    					  $.each(zhe,function(e,q){
    					  	if(e==1){
    					  	zhibos+='<p>直播期间商品打'+q+'折哦</p>';
    					  	}
    					  });
    				zhibos+='</div>'+
    			'</a>'+
    		'</div>';
    		$("#zhibos2").append(zhibos);
    							});
					
				}
			},
			error: function() {
				alert("error");
			}
		});
	      }
}
	




var ss=0;
function selectGoodsList21(){
	 if(currentPage==0||currentPage==1 || currentPage==2 || ss!=0){
	 	   ss2=0;
	 	   ss3=0;
	 	   ss4=0;
          currentPage2=1;
          currentPage3=1;
          currentPage4=1;
	 	 $("#zhibos2").html("");
	 	 $("#zhibos3").html("");
	 	 $("#zhibos4").html("");
	    $.ajax({
        url:urlcore+"/api/zbDirectSeeding/zbDirectSeedingList?current="+currentPage+"&status=2&directType=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
				ss=	data.data.list.length;
		var zhibos="";
				$.each(data.data.list,function(y,n){
						 zhibos+='<div class="zhibo_xinxi">'+
				'<a href="2.2.1zhibo_kaibo_detail.html?zbid='+n.id+'">'+
    				'<div class="zhibo_img">'+
    					'<img onerror="errorImg(this)" src="'+n.imgUrl+'" />'+
    				'</div>'+
    				'<div class="zhibo_wenzi">'+
    					'<dl class="clearfix">'+
    						'<dt>'+
    							'<img src="'+n.user.headImg+'" />'+
    						'</dt>'+
    						'<dd>'+
    							'<h5>'+n.title+'</h5>'+
    						'<span class="zhibo_tip">开播中</span>'+
    						'</dd>'+
    					'</dl>'+
    					'<p>直播期间商品打';
    					  var zhe=n.packRate.toString().split(".");
    					  $.each(zhe,function(e,q){
    					  	if(e==1){
    					  	zhibos+=q+'折哦</p>';
    					  	}
    					  });
    				zhibos+='</div>'+
    			'</a>'+
    		'</div>';
				});
				 $("#zhibos").append(zhibos);
					$(function (){
					$(".jg_simi").click(function(){
    	$("#mask").remove();
        $("body").append("<div id='mask'></div>");
        $(".public_simi").show();
        $("#mask").unbind("click");
        $("#mask").click(function(){
			$(".public_simi").hide();
			setTimeout(function(){
				$("#mask").removeClass("mask");	
				$("#mask").remove();	
			},300);
		});
			});
				})
				}
			},
			error: function() {
				alert("error");
			}
		});
	      }
}
	



function simi(){
	if(currentPage4==1 || currentPage4==2 || ss4!=0){
	
	    $.ajax({
        url:urlcore+"/api/zbDirectSeeding/zbDirectSeedingList?current="+currentPage4+"&directType=2",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					ss4=data.data.length;
				$.each(data.data.list,function(y,n){
    			var shimi='<dl id="'+n.user.userName+'" name="'+n.id+'" onclick="dianji(this)" class="clearfix jg_simi">'+
        		'<dt>'+
        			'<img onerror="errorImg(this)" src="'+n.user.headImg+'" />'+
        			'<i>'+
        				'<img onerror="errorImg(this)" src="images/suo.png" />'+
        			'</i>'+
        		'</dt>'+
        		'<dd>'+
        			'<h5><span>'+n.watchAmount+'人想看</span></h5>'+
        			'<p>'+n.title+'</p>';
        			 if(n.status==1){
        			 	shimi+='<p>直播预告</p>';
        			 }else if(n.status==2){
        			 	shimi+='<p>直播中</p>';
        			 }else if(n.status==3){
        			 	shimi+='<p>历史直播</p>';
        			 }
        			
        		shimi+='</dd>'+
        	'</dl>';
        		$("#zhibos4").append(shimi);
					 });
				$(function (){
					$(".jg_simi").click(function(){
    	$("#mask").remove();
        $("body").append("<div id='mask'></div>");
        $(".public_simi").show();
        $("#mask").unbind("click");
        $("#mask").click(function(){
			$(".public_simi").hide();
			setTimeout(function(){
				$("#mask").removeClass("mask");	
				$("#mask").remove();	
			},300);
		});
			});
				})
				}else{
					alert(data.msg);
				}
			},
			error: function() {
				alert("error");
			}
		});
			
	}
}




function dianji(te){
		$("#dangqian").html("");
		$("#zbid").val("");
	var shopname=$(te).attr("id");
	var shops=$(te).attr("name");
	$("#dangqian").html(shopname);
	$("#zbid").val(shops);
	
}


function jingruzb(){

	  var passwords=$("#passwords").val();
	   var zbid=$("#zbid").val();
	   if(uuuuid!=""){
	   	    if(passwords!=""){
	   	    if(zbid!=""){
	   	   
		 $.ajax({
		url: urlcore + "/api/zbDirectSeeding/applyforentry2",
		type: "post",
		contentType: "application/json;charset=utf-8",
		data: JSON.stringify({
			id:zbid, 
			password:passwords
		}),
		dataType: "json",
		success: function(data) {
			if(data.success == true) {
				alert("正在进入....");
		      window.location.href="2.2.1zhibo_kaibo_detail.html?zbid="+zbid;
		     }else{
		     	alert(data.msg);
		     }
		},error: function() {
			alert("error");
		}
	});
		 	
	   	    }else{
	   	    	alert("出错");
	   	    }
	   	    }else{
	   	    	alert("未输入密码");
	   	    }
	}else{
		alert("未登录/或登录超时");
	}
}




/*function jinru(te){
	  
	
	 
	 
}
*/